<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 86182
  Date: 2024/1/3
  Time: 15:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>查询所有</title>
</head>
<body>
<h1>昆虫信息管理系统</h1>
<form method="post" action="${pageContext.request.contextPath}/select">
    <input type="text" name="name" placeholder="请输入昆虫名">
    <select name="cid">
        <option value="0">--请选择分类--</option>
        <option value="1">有翅斑</option>
        <option value="2">有绒毛</option>
        <option value="3">有复眼</option>
    </select>
    <input type="submit" value="查询">
    <a href="add.jsp">添加昆虫信息</a>
    <table border="1">
        <tr>
            <th>编号</th>
            <th>分类</th>
            <th>昆虫名</th>
            <th>寿命</th>
            <th>地域分布</th>
            <th>首次发现时间</th>
            <th>操作</th>
        </tr>
        <c:forEach items="${list}" var="insect">
            <tr>
                <td>${insect.id}</td>
                <td>${insect.cid}</td>
                <td>${insect.name}</td>
                <td>${insect.life}</td>
                <td>${insect.area}</td>
                <td>${insect.discovery_time}</td>
                <td>
                    <a href="#" onclick="del(${insect.id})">删除</a>
                </td>
            </tr>
        </c:forEach>
    </table>
</form>
</body>
<script src="js/jquery.js"></script>
<script>
    function del(id){
        var isdel=confirm('确定删除？');
        if (isdel){
            location.href="${pageContext.request.contextPath}/del?id="+id;
        }
    }
    $("tr:even").css("background-color","#ccc")
</script>
</html>
